package com.fr.report;

import com.fr.base.ColumnRow;
import com.fr.base.StringUtils;
import com.fr.base.background.Background;
import com.fr.base.background.ColorBackground;
import com.fr.base.xml.BaseXMLUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLReadable;
import com.fr.base.xml.XMLableReader;
import com.fr.report.io.xml.SynchronizedFrozenColumnRow;
import com.fr.report.web.EmailManager;
import com.fr.report.web.Printer;
import com.fr.report.web.ToolBarManager;
import com.fr.report.web.WebForm;
import com.fr.report.web.WebPage;
import com.fr.report.web.WebView;
import com.fr.report.web.WebWrite;
import java.awt.Color;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class ReportWebAttr
  implements XMLReadable, Cloneable, Serializable
{
  private String title = null;
  private EmailManager email;
  private Printer printer;
  private WebPage page = null;
  private WebView view = null;
  private WebForm form = null;
  private WebWrite write = null;
  private List jsImportList = null;
  private List cssImportList = null;
  private List writeCssImportList = null;
  private List widgetCssImportList = null;
  private Background background = null;
  private long cacheValidateTime = 0L;

  public String getTitle()
  {
    return this.title;
  }

  public void setTitle(String paramString)
  {
    this.title = paramString;
  }

  public void setCacheValidateTime(long paramLong)
  {
    this.cacheValidateTime = paramLong;
  }

  public long getCacheValidateTime()
  {
    return this.cacheValidateTime;
  }

  public WebPage getWebPage()
  {
    return this.page;
  }

  public void setWebPage(WebPage paramWebPage)
  {
    this.page = paramWebPage;
  }

  public WebView getWebView()
  {
    return this.view;
  }

  public void setWebView(WebView paramWebView)
  {
    this.view = paramWebView;
  }

  public WebForm getWebForm()
  {
    return this.form;
  }

  public void setWebForm(WebForm paramWebForm)
  {
    this.form = paramWebForm;
  }

  public WebWrite getWebWrite()
  {
    return this.write;
  }

  public void setWebWrite(WebWrite paramWebWrite)
  {
    this.write = paramWebWrite;
  }

  public EmailManager getEmailManager()
  {
    return this.email;
  }

  public void setEmailManager(EmailManager paramEmailManager)
  {
    this.email = paramEmailManager;
  }

  public Printer getPrinter()
  {
    return this.printer;
  }

  public void setPrinter(Printer paramPrinter)
  {
    this.printer = paramPrinter;
  }

  public Background getBackground()
  {
    return this.background;
  }

  public void setBackground(Background paramBackground)
  {
    this.background = paramBackground;
  }

  public int getJSImportCount()
  {
    return ((this.jsImportList == null) ? 0 : this.jsImportList.size());
  }

  public String getJSImport(int paramInt)
  {
    return ((this.jsImportList == null) ? null : (String)this.jsImportList.get(paramInt));
  }

  public void clearJSImportList()
  {
    if (this.jsImportList != null)
      this.jsImportList.clear();
  }

  public void addJSImport(String paramString)
  {
    if (this.jsImportList == null)
      this.jsImportList = new ArrayList();
    this.jsImportList.add(paramString);
  }

  public int getCSSImportCount()
  {
    return ((this.cssImportList == null) ? 0 : this.cssImportList.size());
  }

  public String getCSSImport(int paramInt)
  {
    return ((this.cssImportList == null) ? null : (String)this.cssImportList.get(paramInt));
  }

  public void clearCSSImportList()
  {
    if (this.cssImportList != null)
      this.cssImportList.clear();
  }

  public void addCSSImport(String paramString)
  {
    if (this.cssImportList == null)
      this.cssImportList = new ArrayList();
    this.cssImportList.add(paramString);
  }

  public int getWriteCSSImportCount()
  {
    return ((this.writeCssImportList == null) ? 0 : this.writeCssImportList.size());
  }

  public String getWriteCSSImport(int paramInt)
  {
    return ((this.writeCssImportList == null) ? null : (String)this.writeCssImportList.get(paramInt));
  }

  public void clearWriteCSSImportList()
  {
    if (this.writeCssImportList != null)
      this.writeCssImportList.clear();
  }

  public void addWriteCSSImport(String paramString)
  {
    if (this.writeCssImportList == null)
      this.writeCssImportList = new ArrayList();
    this.writeCssImportList.add(paramString);
  }

  public int getWidgetCSSImportCount()
  {
    return ((this.widgetCssImportList == null) ? 0 : this.widgetCssImportList.size());
  }

  public String getWidgetCSSImport(int paramInt)
  {
    return ((this.widgetCssImportList == null) ? null : (String)this.widgetCssImportList.get(paramInt));
  }

  public void clearWidgetCSSImportList()
  {
    if (this.widgetCssImportList != null)
      this.widgetCssImportList.clear();
  }

  public void addWidgetCSSImport(String paramString)
  {
    if (this.widgetCssImportList == null)
      this.widgetCssImportList = new ArrayList();
    this.widgetCssImportList.add(paramString);
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str1;
      String str2 = paramXMLableReader.getTagName();
      if (str2.equals("Title"))
      {
        if (StringUtils.isNotBlank(str1 = paramXMLableReader.getElementValue()))
          setTitle(str1);
      }
      else if (str2.equals("ServerPrinter"))
      {
        this.printer = new Printer();
        paramXMLableReader.readXMLObject(this.printer);
      }
      else if (str2.equals("EmailManager"))
      {
        this.email = new EmailManager();
        paramXMLableReader.readXMLObject(this.email);
      }
      else if (str2.equals("Background"))
      {
        setBackground(BaseXMLUtils.readBackground(paramXMLableReader));
      }
      else if (str2.equals("CSSImport"))
      {
        if ((str1 = paramXMLableReader.getElementValue()) != null)
          addCSSImport(str1);
      }
      else if (str2.equals("WriteCSSImport"))
      {
        if ((str1 = paramXMLableReader.getElementValue()) != null)
          addWriteCSSImport(str1);
      }
      else if (str2.equals("WidgetCSSImport"))
      {
        if ((str1 = paramXMLableReader.getElementValue()) != null)
          addWidgetCSSImport(str1);
      }
      else if (str2.equals("JSImport"))
      {
        if ((str1 = paramXMLableReader.getElementValue()) != null)
          addJSImport(str1);
      }
      else if (str2.equals("WebPageContent"))
      {
        this.page = new WebPage();
        paramXMLableReader.readXMLObject(this.page);
      }
      else if (str2.equals("WebViewContent"))
      {
        this.view = new WebView();
        paramXMLableReader.readXMLObject(this.view);
      }
      else if (str2.equals("WebWriteContent"))
      {
        this.write = new WebWrite();
        paramXMLableReader.readXMLObject(this.write);
      }
      else if ("WebFormContent".equals(str2))
      {
        this.form = new WebForm();
        paramXMLableReader.readXMLObject(this.form);
      }
      else if ("CacheValidateTime".equals(str2))
      {
        setCacheValidateTime(Long.parseLong(paramXMLableReader.getElementValue()));
      }
      else
      {
        Object localObject;
        if (str2.equals("ToolbarManager"))
        {
          localObject = new ToolBarManager();
          paramXMLableReader.readXMLObject((Serializable)localObject);
          if (this.page == null)
            this.page = new WebPage();
          this.page.setToolBarManagers(new ToolBarManager[] { localObject });
        }
        else if (str2.equals("FrozenColumnRow"))
        {
          if ((str1 = paramXMLableReader.getAttr("FrozenColumnRow")) == null)
            if ((str1 = paramXMLableReader.getAttr("frozenColumnRow")) == null)
              return;
          localObject = ColumnRow.valueOf(str1);
          if (this.write == null)
            this.write = new WebWrite();
          SynchronizedFrozenColumnRow.putSynchronizedFrozenColumnRow((ColumnRow)localObject);
        }
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if (StringUtils.isNotBlank(getTitle()))
      paramXMLPrintWriter.startTAG("Title").textNode(getTitle()).end();
    if (this.email != null)
      this.email.writeXML(paramXMLPrintWriter);
    if (this.printer != null)
      this.printer.writeXML(paramXMLPrintWriter);
    if (this.page != null)
    {
      paramXMLPrintWriter.startTAG("WebPageContent");
      this.page.writeXML(paramXMLPrintWriter);
      paramXMLPrintWriter.end();
    }
    if (this.view != null)
    {
      paramXMLPrintWriter.startTAG("WebViewContent");
      this.view.writeXML(paramXMLPrintWriter);
      paramXMLPrintWriter.end();
    }
    if (this.form != null)
    {
      paramXMLPrintWriter.startTAG("WebFormContent");
      this.form.writeXML(paramXMLPrintWriter);
      paramXMLPrintWriter.end();
    }
    if (this.write != null)
    {
      paramXMLPrintWriter.startTAG("WebWriteContent");
      this.write.writeXML(paramXMLPrintWriter);
      paramXMLPrintWriter.end();
    }
    Background localBackground = getBackground();
    if (!(ColorBackground.getInstance(Color.white).equals(localBackground)))
      BaseXMLUtils.writeBackground(paramXMLPrintWriter, localBackground);
    int i = 0;
    int j = getCSSImportCount();
    while (i < j)
    {
      paramXMLPrintWriter.startTAG("CSSImport").textNode(getCSSImport(i)).end();
      ++i;
    }
    i = 0;
    j = getWriteCSSImportCount();
    while (i < j)
    {
      paramXMLPrintWriter.startTAG("WriteCSSImport").textNode(getWriteCSSImport(i)).end();
      ++i;
    }
    i = 0;
    j = getWidgetCSSImportCount();
    while (i < j)
    {
      paramXMLPrintWriter.startTAG("WidgetCSSImport").textNode(getWidgetCSSImport(i)).end();
      ++i;
    }
    i = 0;
    j = getJSImportCount();
    while (i < j)
    {
      paramXMLPrintWriter.startTAG("JSImport").textNode(getJSImport(i)).end();
      ++i;
    }
    paramXMLPrintWriter.startTAG("CacheValidateTime").textNode(String.valueOf(this.cacheValidateTime)).end();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    ReportWebAttr localReportWebAttr = (ReportWebAttr)super.clone();
    if (this.background != null)
      localReportWebAttr.background = ((Background)this.background.clone());
    if (this.email != null)
      localReportWebAttr.email = ((EmailManager)this.email.clone());
    if (this.printer != null)
      localReportWebAttr.printer = ((Printer)this.printer.clone());
    if (this.page != null)
      localReportWebAttr.page = ((WebPage)this.page.clone());
    if (this.view != null)
      localReportWebAttr.view = ((WebView)this.view.clone());
    if (this.form != null)
      localReportWebAttr.form = ((WebForm)this.form.clone());
    if (this.write != null)
      localReportWebAttr.write = ((WebWrite)this.write.clone());
    if (this.cssImportList != null)
    {
      localReportWebAttr.cssImportList = new ArrayList();
      localReportWebAttr.cssImportList.addAll(this.cssImportList);
    }
    if (this.writeCssImportList != null)
    {
      localReportWebAttr.writeCssImportList = new ArrayList();
      localReportWebAttr.writeCssImportList.addAll(this.writeCssImportList);
    }
    if (this.widgetCssImportList != null)
    {
      localReportWebAttr.widgetCssImportList = new ArrayList();
      localReportWebAttr.widgetCssImportList.addAll(this.widgetCssImportList);
    }
    if (this.jsImportList != null)
    {
      localReportWebAttr.jsImportList = new ArrayList();
      localReportWebAttr.jsImportList.addAll(this.jsImportList);
    }
    return localReportWebAttr;
  }
}